import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/widgets/app/app_upload.dart';
import 'package:bxultimate/widgets/mk_page.dart';
import 'package:bxultimate/widgets/mk_scroll_view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import 'controller.dart';

class FeedBackPage extends StatefulWidget {
  const FeedBackPage({Key? key}) : super(key: key);

  @override
  State<FeedBackPage> createState() => _FeedBackPageState();
}

class _FeedBackPageState extends State<FeedBackPage> {
  final controller = Get.find<FeedBackController>();
  final state = Get.find<FeedBackController>().state;

  @override
  Widget build(BuildContext context) {
    return MkPage(
      child: Scaffold(
        backgroundColor: Colors.transparent,
        appBar: TDNavBar(
          backgroundColor: Colors.transparent,
          title: '意见反馈',
        ),
        body: MkScrollView(
          bottomButton: TDButton(
            text: '提交',
            shape: TDButtonShape.circle,
            height: 48,
            onTap: controller.save,
            isBlock: true,
            theme: TDButtonTheme.primary,
          ),
          children: [
            TDInput(
              controller: controller.feedbackController,
              leftLabel: '问题和意见',
              hintText: '请填写10字以上的问题描述,以便我们为您提供更好的帮助',
              maxLines: 4,
              required: true,
              type: TDInputType.special,
              textAlign: TextAlign.start,
              backgroundColor: Colors.transparent,
            ),
            TDInput(
              controller: controller.contactController,
              leftLabel: '联系方式',
              required: true,
              hintText: '请输入联系方式',
              type: TDInputType.special,
              textAlign: TextAlign.end,
              backgroundColor: Colors.transparent,
            ),
            Padding(
              padding: EdgeInsets.all(AppTheme.iDefaultPadding + 4),
              child: Row(
                children: [
                  Text(
                    '提供问题截图等',
                    style: TextStyle(fontSize: 16),
                  ),
                ],
              ),
            ),
            Obx(() => Padding(
                padding: EdgeInsets.only(left: AppTheme.iDefaultPadding),
                child: AppUpload(
                  maxCount: 1,
                  imgList: state.imgList,
                  videoList: state.videoList,
                )))
          ],
        ),
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<FeedBackController>();
    super.dispose();
  }
}